<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>登陆页面</title>
<link href="css/bootstrap.css" rel="stylesheet">
<style type="text/css">
form {
	margin-left: 50px;
	margin-top: 100px;
}
</style>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
	$(function() {
		$("#sub").click(function() {
			if ($("#inputEmail").val() == "") {
				alert("用户名不能为空");
			} else if ($("#inputPassword").val() == "") {
				alert("密码不能为空");
			} else {
				//账号密码都不为空，可以异步验证账户信息
				$.ajax({
					url : "http://localhost:8080/crm/login",
					type : "post",
					data : $("form").serialize(),
					success : function(data) {
						//data就是Courier对象
						if (data.message != "登陆成功") {
							alert(data.message);
						} else {
							alert("欢迎登陆：" + data.username);
							// 跳转到index后台
							window.location.href = "index";
						}
					}
				});
			}
		});
	});
</script>

</head>
<body>

	<form class="form-horizontal" action="" method="post">
		<div class="control-group">
			<label class="control-label">账号</label>
			<div class="controls">
				<input type="text" class="input-xxlarge" id="inputEmail"
					placeholder="请输入用户名" name="usrName">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputPassword">密码</label>
			<div class="controls">
				<input type="password" class="input-xxlarge" id="inputPassword"
					placeholder="请输入密码" name="usrPassword">
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<label class="checkbox"> <input type="checkbox"> 记住我
				</label>
				<button type="button" class="btn btn-primary" id="sub">登录</button>
			</div>
		</div>
	</form>





</body>
</html>
